package com.paradisecloudtech.vc.system.ui.fragment;

import android.support.v4.app.Fragment;

import com.common.library.base.BaseFragment;
import com.paradisecloudtech.vc.system.R;
import com.paradisecloudtech.vc.system.adapter.CenterViewPagerAdapter;
import com.paradisecloudtech.vc.system.ui.widget.ScrollViewPager;

import java.util.ArrayList;

import butterknife.BindView;

public class CenterFragment extends BaseFragment {

    @BindView(R.id.vp_center)
    ScrollViewPager svpCenter;

    public static CenterFragment centerFragment;

    public CenterFragment() {

    }

    public static CenterFragment getInstance() {
        if (centerFragment == null) {
            centerFragment = new CenterFragment();
        }
        return centerFragment;
    }

    @Override
    public int getLayoutId() {
        return R.layout.fragment_center;
    }

    @Override
    protected void initVar() {

    }

    @Override
    public void initData() {
        ConfsFragment confsFragment = ConfsFragment.getInstance();
        ServiceFragment serviceFragment = ServiceFragment.getInstance();
        ArrayList<Fragment> baseFragments = new ArrayList<>();
        baseFragments.add(confsFragment);
        baseFragments.add(serviceFragment);

        CenterViewPagerAdapter adapter = new CenterViewPagerAdapter(getFragmentManager(), baseFragments);
        svpCenter.setCancelScroll(true);
        svpCenter.setAdapter(adapter);
    }

    @Override
    public void initListener() {

    }

    public void slideItemClick(int id) {
        switch (id) {
            case R.id.rl_slide_item_1:
                svpCenter.setCurrentItem(0);
                break;

            case R.id.rl_slide_item_2:
                svpCenter.setCurrentItem(1);
                break;
        }
    }
}
